package com.tuo51.evaluate.controller;


import com.matt.commons.dto.sso.AreaDTO;
import com.matt.commons.model.StatusResponse;
import com.matt.commons.page.PagerQuery;
import com.matt.foundation.model.MemVerificationCache;
import com.tuo51.evaluate.service.EvaluateStatisticsService;
import com.tuo51.evaluate.service.EvaluateV2ExportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import static com.matt.foundation.constant.RequestConstant.TICKET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;


@RestController
@RequestMapping("/eapi/statistics")
@Api(value = "/eapi/statistics", tags = "测评 - 统计信息")
public class EvaluateStatisticsController {

    @Autowired
    private EvaluateStatisticsService evaluateStatisticsService;

    @Autowired
    protected MemVerificationCache cache;

    @RequestMapping(value = "/count", method = POST)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "ticket", value = "票据", required = true, dataType = "string"),
    })
    public StatusResponse getEvaluateCount(@RequestHeader(TICKET) String ticket, PagerQuery pagerQuery ){
        AreaDTO areaDTO = cache.getArea(ticket);
        return StatusResponse.success(evaluateStatisticsService.getEvaluateCount(areaDTO.getId(),pagerQuery));
    }

}
